/**
 * Created by SCR on 2017/8/9.
 */

var mongoose = require('../mongooseModel');

var mongodb = require('../mongoDB');
var ObjectId = require('mongodb').ObjectID;
var ModelBase = require('../modelBase');

function visualization(visualization){
    if(visualization){
        for(var key in visualization){
            this[key] = visualization[key];
        }
        if(!visualization._id){
            this._id = new ObjectId();
        }
    }
    else{
        this._id = new ObjectId();
        this.DVM = {};
        this.schemas = [];
        this.time = (new Date()).getTime();
    }
}

visualization.__proto__ = ModelBase;
module.exports = visualization;

var visualizationSchema = new mongoose.Schema({
    DVM:mongoose.Schema.Types.Mixed,
    schemas: Array,
    time:Number
},{collection:'visualizationPackage'});

var visualizationModel = mongoose.model('visualizationPackage',visualizationSchema);
visualization.baseModel = visualizationModel;
visualization.modelName = 'visualizationPackage';
